﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace CoinsLibrary
{
    public static class DHTools
    {
        public static long GetTimeStamp()
        {
            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            return Convert.ToInt64(ts.TotalSeconds);
        }
        public static string GetMd5(object text, string lv = "")
        {
            MD5CryptoServiceProvider MD5Pro = new MD5CryptoServiceProvider();
            Byte[] buffer = Encoding.GetEncoding("utf-8").GetBytes(text.ToString() + lv);
            Byte[] byteResult = MD5Pro.ComputeHash(buffer);
            return BitConverter.ToString(byteResult).Replace("-", "");
        }
        public static void SetLog(string str, string path = "log.log")
        {
            str = DateTime.Now.ToString() + "--" + str;
            System.IO.File.AppendAllText(path, str + "\r\n");
        }
    }
}
